package com.zcx.qshop.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.zcx.helper.bound.BoundView;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.R;
import com.zcx.qshop.adapter.BalanceAdapter;
import com.zcx.qshop.conn.JsonAcountAsyGet;
import com.zcx.qshop.view.TitleView;

/**
 * Created by Administrator on 2015/11/28.
 */
public class BalanceActivity extends QSActivity {

    @BoundView(R.id.title_view) private TitleView titleView;

    @BoundView(R.id.balance_layout) private View layout;

    @BoundView(R.id.balance_acount) private TextView acount;

    @BoundView(R.id.balance_recharge) private View recharge;

    @BoundView(R.id.balance_list_view) private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_balance);

        titleView.showStyle(TitleView.Style.FULL);

        titleView.showType(TitleView.Type.BACK_TWO, TitleView.Type.NAME_ONE);

        titleView.setTitleName("我的余额");

        titleView.setOnTitleItemClickListener(new TitleView.OnTitleItemClickListener() {

            @Override
            public void onBackClick() {

                finish();

            }

        });

        new JsonAcountAsyGet(QSApplication.QSPreferences.readUid(), new AsyCallBack<JsonAcountAsyGet.Info>(){

            @Override
            public void onSuccess(String toast, int type, JsonAcountAsyGet.Info info) throws Exception {

                layout.setVisibility(View.VISIBLE);

                acount.setText(info.acount);

                listView.setAdapter(new BalanceAdapter(BalanceActivity.this, info.acounts));

                recharge.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        startVerifyActivity(RechargeActivity.class);

                    }

                });

            }

        }).execute(this);

    }

}
